package com.pbdevj.ssm.util;

import java.util.HashMap;
import java.util.Map;

public class GenerateJsonMessageWithPageHelper
{
	// 状态码
	private int statusCode;

	// 提示信息
	private String promptMessage;

	// 服务器返回客户端的JSON数据
	private Map<String, Object> jsonMessage = new HashMap<>();

	public int getStatusCode()
	{
		return statusCode;
	}

	public void setStatusCode(int statusCode)
	{
		this.statusCode = statusCode;
	}

	public String getPromptMessage()
	{
		return promptMessage;
	}

	public void setPromptMessage(String promptMessage)
	{
		this.promptMessage = promptMessage;
	}

	public Map<String, Object> getJsonMessage()
	{
		return jsonMessage;
	}

	public void setJsonMessage(Map<String, Object> jsonMessage)
	{
		this.jsonMessage = jsonMessage;
	}

	// 返回成功
	public static GenerateJsonMessageWithPageHelper success()
	{
		GenerateJsonMessageWithPageHelper jsonData = new GenerateJsonMessageWithPageHelper();

		jsonData.setStatusCode(200);

		jsonData.setPromptMessage("返回成功！");

		return jsonData;
	}

	// 返回失败
	public static GenerateJsonMessageWithPageHelper fail()
	{
		GenerateJsonMessageWithPageHelper jsonStatusCode = new GenerateJsonMessageWithPageHelper();

		jsonStatusCode.setStatusCode(500);

		jsonStatusCode.setPromptMessage("返回失败！");

		return jsonStatusCode;
	}

	public GenerateJsonMessageWithPageHelper add(String key, Object value)
	{
		this.getJsonMessage().put(key, value);
		
		return this;
	}

}
